using System;

namespace Headsight.BPMN2WF.BPMN.Model
{
    /// <summary>
    /// Base class for all BPMN elements.
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public abstract class BPMNBaseElement<T>
    {
        protected BPMNBaseElement(T tNode, String id)
        {
            TElement = tNode;
            Id = id;
        }

        /// <summary>
        /// The actual raw <i>BPMN tElement</i>.
        /// </summary>
        public T TElement { get; protected set; }

        /// <summary>
        /// The actual raw <i>BPMN tElement's id</i>.
        /// </summary>
        public String Id { get; protected set; }

        public override bool Equals(object obj)
        {
            var oObj = obj as BPMNBaseElement<T>;

            if (oObj == null)
            {
                return false;
            }

            return Id == oObj.Id;
        }

        public override int GetHashCode()
        {
            return (Id == null) ? 0 : Id.GetHashCode();
        }

        public override string ToString()
        {
            return String.Format("{0}[Id: {1}]", GetType().Name, Id);
        }
    }
}